<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as AuthUser;

class Users extends AuthUser
{
    protected $table = "users"; //指定表
    protected $primaryKey = "id"; //指定id字段
    public $timestamps = false; //关闭时间自动

    protected $hidden = [
        'password', 'remember_token',
    ];

    protected $fillable = [
        'username', 'email', 'password','nick','is_admin','is_teacher'
    ];

    // 获取所有用户的学习科目
    public function user_subject(){
    	return $this->hasMany('App\Model\UserSubject','user_id','id');
    }

    // 获取默认的用户学习科目
    public function user_subject_row(){
    	return $this->hasMany('App\Model\UserSubject','user_id','id')->where('is_default',1)->first();
    }

}
